package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T24;
import com.ruoyi.service.IT24Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流程Controller
 *
 * @author ruoyi
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/T24")
public class T24Controller extends BaseController
{
    @Autowired
    private IT24Service t24Service;

    /**
     * 查询流程列表
     */

    @GetMapping("/list")
    public TableDataInfo list(T24 t24)
    {
        startPage();
        List<T24> list = t24Service.selectT24List(t24);
        return getDataTable(list);
    }

    /**
     * 导出流程列表
     */

    @Log(title = "流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, T24 t24)
    {
        List<T24> list = t24Service.selectT24List(t24);
        ExcelUtil<T24> util = new ExcelUtil<T24>(T24.class);
        util.exportExcel(response, list, "流程数据");
    }

    /**
     * 获取流程详细信息
     */

    @GetMapping(value = "/{F2401}")
    public AjaxResult getInfo(@PathVariable("F2401") String F2401)
    {
        return success(t24Service.selectT24ByF2401(F2401));
    }

    /**
     * 新增流程
     */

    @Log(title = "流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody T24 t24)
    {
        return toAjax(t24Service.insertT24(t24));
    }

    /**
     * 修改流程
     */

    @Log(title = "流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody T24 t24)
    {
        return toAjax(t24Service.updateT24(t24));
    }

    /**
     * 删除流程
     */

    @Log(title = "流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{F2401s}")
    public AjaxResult remove(@PathVariable String[] F2401s)
    {
        return toAjax(t24Service.deleteT24ByF2401s(F2401s));
    }


    @GetMapping("/getByF0614")
    public AjaxResult getByF0614(@RequestParam("F0614") String F0614)
    {
        List<T24> list = t24Service.selectT24ByF2405(F0614);
        return success(list);
    }
}
